﻿using FineAdmin.IService;
using FineAdmin.Model;
using FineAdmin.Web.Controllers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace FineAdmin.Web.Areas.Shop.Controllers
{
    public class GoodsSetController : BaseController
    {
        // GET: Shop/GoodsSet
       // public IMaterialGoodsService MaterialGoodsService { get; set; }
        public override ActionResult Index(int? id)
        {
            base.Index(id);
            return View();
        }
        [HttpGet]
        public JsonResult List(MaterialGoodsModel model, PageInfo pageInfo)
        {
            pageInfo.field = "Id";
            pageInfo.order = "desc";
            var result = MaterialGoodsService.GetListByFilter(model, pageInfo);
            return Json(result, JsonRequestBehavior.AllowGet);
        }

        public ActionResult Edit(int id)
        {

            var model = MaterialGoodsService.GetById(id);
            return View(model);
        }
        [HttpPost]
        public ActionResult Edit(MaterialGoodsModel model)
        {
            model.UpdateTime = DateTime.Now;
            model.UpdateUserId = Operator.UserId;
            var result = MaterialGoodsService.UpdateById(model) ? SuccessTip("修改成功") : ErrorTip("修改失败");
            return Json(result);
        }

        public JsonResult OverData()
        {
            var ret = MaterialGoodsService.OverData();
            var result = ret >= 0 ? SuccessTip("成功") : ErrorTip("失败");
            return Json(result, JsonRequestBehavior.AllowGet);
        }

    }
}